#include <REGX52.H>
#include "Delay.h"
#include "Nixie.h"
#include "MatrixKey.h"

sbit Buzzer=P2^5;
unsigned char key,key1,key2,key3,key4,key5,m;
unsigned int passw;
void main()
{		
	Buzzer=0;
	while(1)
	{
        key=m;
        passw+=key;
        
        while(key==m)
        {
            if(passw<10)
            {nixie(1,passw);}
            if(passw>=10&&passw<100)
            {key1=passw/10;key2=passw%10;nixie(1,key1);nixie(2,key2);}
            if(passw>=100&&passw<1000)
            {key1=passw/100;key2=passw%100/10;key3=passw%10;nixie(1,key1);nixie(2,key2);nixie(3,key3);}
            if(passw>=1000&&passw<10000)
            {key1=passw/1000;key2=passw%1000/100;key3=passw%100/10;key4=passw%10;nixie(1,key1);nixie(2,key2);nixie(3,key3);nixie(4,key4);}
            if (passw>=10000)
            {
                while(1)
                {
                    nixie(1,key1);
                    nixie(2,key2);
                    nixie(3,key3);
                    nixie(4,key4);
                    nixie(5,key5);
                }
            }
            m= MatrixKey();

        }
        if(passw==1234)
        {key5=1;}
        else{key5=2;}   
//	    passw*=10;

    }
}
//8   8   